//
//  QMQCCityViewController.m
//  QcMedical1
//
//  Created by 仲启明 on 2016/12/21.
//  Copyright © 2016年 jiawen Du. All rights reserved.
//

#import "QMQCCityViewController.h"
#import "QMQCCityModel.h"
@interface QMQCCityViewController ()
@property (nonatomic, strong) NSArray *cityArray;
@end

@implementation QMQCCityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)loadData
{
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"province.plist" ofType:nil];
    
    NSArray *dicArray = [NSArray arrayWithContentsOfFile:filePath];
    
    NSMutableArray *cityArray = [NSMutableArray array];
    
    for (NSDictionary *dic in dicArray) {
        
        QMQCCityModel *model = [[QMQCCityModel alloc] init];
        
        [model setValuesForKeysWithDictionary:dic];
        
        [cityArray addObject:model];
    }
    
    self.cityArray = cityArray.copy;
}

- (void)setupUI
{
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.cityArray.count;;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    QMQCCityModel *model = self.cityArray[indexPath.row];
    
    cell.textLabel.text = model.name;
    
    return cell;
}
@end
